package cn.hucode.chapter2.service;

import cn.hucode.chapter2.helper.DatabaseHelper;
import cn.hucode.chapter2.model.Customer;
import cn.hucode.chapter2.util.PropsUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;

/**
 * @author jiajian
 * @date 2016/12/1
 */
public class CustomerService {
    private static Logger logger = LoggerFactory.getLogger(CustomerService.class);

    public List<Customer> getList(String name){
        String sql = "select * from customer";
        return DatabaseHelper.queryEntityList(Customer.class, sql);
    }

    public Customer get(Long id){
        // TODO: 2016/12/1
        return null;
    }

    public boolean create(Map<String, Object> fieldMap){
        return DatabaseHelper.insertEntity(Customer.class, fieldMap);
    }

    public boolean update(long id, Map<String, Object> fieldMap){
        return DatabaseHelper.updateEntity(Customer.class, id, fieldMap);
    }

    public boolean delete(Long id){
        return DatabaseHelper.deleteEntity(Customer.class, id);
    }
}
